package com.cq.hd.merchant.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.system.api.TbContentApi;
import com.cq.hd.system.api.TbContentCategoryApi;
import com.cq.hd.system.api.dto.ContentCategoryPageDto;
import com.cq.hd.system.api.dto.ContentPageDto;
import com.cq.hd.system.api.vo.ContentCategoryPageVo;
import com.cq.hd.system.api.vo.ContentPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/content")
@Api(tags = "火火学院相关接口")
public class ContentController {

    @Autowired
    private TbContentCategoryApi contentCategoryApi;

    @Autowired
    private TbContentApi contentApi;

    @ApiOperation(value = "学院分类列表")
    @ApiImplicitParam(name = "contentCategoryPageDto", value = "学院分类查询参数", required = true, paramType = "query", dataType = "ContentCategoryPageDto")
    @ApiResponse(response = ContentCategoryPageVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/pageContentCategory")
    public Result<Page<ContentCategoryPageVo>> pageContentCategory() {
        ContentCategoryPageDto contentCategoryPageDto = new ContentCategoryPageDto();
        // 内容端口(1-火动学堂，2-商户学堂)
        contentCategoryPageDto.setContentPort(2);
        return contentCategoryApi.pageContentCategory(contentCategoryPageDto);
    }

    @ApiOperation(value = "学院文章列表")
    @ApiImplicitParam(name = "contentPageDto", value = "学院文章查询参数", required = true, paramType = "query", dataType = "ContentPageDto")
    @ApiResponse(response = ContentPageVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/pageContent")
    public Result<Page<ContentPageVo>> pageContent(ContentPageDto contentPageDto) {
        // 内容端口(1-火动学堂，2-商户学堂)
        contentPageDto.setContentPort(2);
        // 状态（1-上架，2-下架）
        contentPageDto.setState(1);
        contentPageDto.setOrderType(1);
        return contentApi.pageContent(contentPageDto);
    }


}
